package com.libc.yygh.cmn.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.libc.yygh.cmn.mapper.DictMapper;
import com.libc.yygh.model.cmn.Dict;
import com.libc.yygh.vo.cmn.DictEeVo;
import org.springframework.beans.BeanUtils;

/**
 * *
 * Created with Description:
 *
 * @fileRelativePath: DictListener.java
 * @Date: Created on 2022/6/6  0:09  <br>
 * @author: LiBencheng <br>
 * @version: 1.0 <br>
 */
public class DictListener extends AnalysisEventListener< DictEeVo >
{

    private DictMapper dictMapper;

    public DictListener(DictMapper dictMapper)
    { this.dictMapper = dictMapper; }

    //一行一行读取
    @Override
    public void invoke(DictEeVo dictEeVo, AnalysisContext analysisContext)
    {
        //调用方法添加数据库
        Dict dict = new Dict();
        BeanUtils.copyProperties(dictEeVo, dict);
        dictMapper.insert(dict);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext)
    {

    }
}
